//封装本地存储数据与读取通话方式的方法
export const SET_CALLTYPE = (callType: string) => {
    localStorage.setItem('CALLTYPE', JSON.stringify(callType))
}

export const GET_CALLTYPE = () => {
    const callType = localStorage.getItem('CALLTYPE')
    return callType ? JSON.parse(callType) : ''
}

export const REMOVE_CALLTYPE = () => {
    localStorage.removeItem('CALLTYPE')
}

//封装本地存储数据与读取远程应答SDP描述的方法
export const SET_RECEIVEDSDP = (receivedSDP: any) => {
    localStorage.setItem('RECEIVEDSDP', JSON.stringify(receivedSDP))
}

export const GET_RECEIVEDSDP = () => {
    const receivedSDP = localStorage.getItem('RECEIVEDSDP')
    return receivedSDP ? JSON.parse(receivedSDP) : null
}

export const REMOVE_RECEIVEDSDP = () => {
    localStorage.removeItem('RECEIVEDSDP')
}

//封装本地存储数据与读取通话状态的方法(拨打)
export const SET_CALLTO = (callTo: boolean) => {
    localStorage.setItem('CALLTO', JSON.stringify(callTo))
}

export const GET_CALLTO = () => {
    const callTo = localStorage.getItem('CALLTO')
    return callTo ? JSON.parse(callTo) : false
}

export const REMOVE_CALLTO = () => {
    localStorage.removeItem('CALLTO')
}

//封装本地存储数据与读取通话状态的方法(来电)
export const SET_INCOMINGCALL = (incomingCall: boolean) => {
    localStorage.setItem('INCOMINGCALL', JSON.stringify(incomingCall))
}

export const GET_INCOMINGCALL = () => {
    const incomingCall = localStorage.getItem('INCOMINGCALL')
    //检查存储的值是否存在，然后将其解析为对象
    return incomingCall ? JSON.parse(incomingCall) : false
}

export const REMOVE_INCOMINGCALL = () => {
    localStorage.removeItem('INCOMINGCALL')
}

//封装本地存储数据与读取通话状态的方法(通话中)
export const SET_ISCALLING = (iscalling: boolean) => {
    localStorage.setItem('ISCALLING', JSON.stringify(iscalling))
}

export const GET_ISCALLING = () => {
    const iscalling = localStorage.getItem('ISCALLING')
    //检查存储的值是否存在，然后将其解析为对象
    return iscalling ? JSON.parse(iscalling) : false
}

export const REMOVE_ISCALLING = () => {
    localStorage.removeItem('ISCALLING')
}

//封装本地存储数据与读取来电好友信息的方法
export const SET_VIDEOINFO = (videoInfo: any) => {
    localStorage.setItem('VIDEOINFO', JSON.stringify(videoInfo))
}

export const GET_VIDEOINFO = () => {
    const videoInfo = localStorage.getItem('VIDEOINFO')
    //检查存储的值是否存在，然后将其解析为对象
    return videoInfo ? JSON.parse(videoInfo) : null
}

export const REMOVE_VIDEOINFO = () => {
    localStorage.removeItem('VIDEOINFO')
}
